Skip to content

Support listing nested objects#323

Closed
whyscream wants to merge 6 commits intomasterfrom
315-support-listing-nested-objects
Closed

Support listing nested objects#323
whyscream wants to merge 6 commits intomasterfrom
315-support-listing-nested-objects

Conversation

@whyscream
Copy link
Copy Markdown
Contributor

Related to #315

This resolves the issue when paginating over 'nested' resources. In stead of injecting a parent object into resource that manages the childs, we just retrieve the childs from a custom resource path (that happens to include the parent id).

For now this is a POC: it only works for subscriptions (nested below a customer) and subscription payments (nested below customer and subscription).

@whyscream whyscream force-pushed the 315-support-listing-nested-objects branch 2 times, most recently from 0848749 to 15ce257 Compare June 22, 2023 16:41
Comment thread mollie/api/objects/customer.py Outdated
Comment on lines +45 to +47
url = self._get_link("subscriptions")

from ..resources import CustomerSubscriptions

return CustomerSubscriptions(self.client, resource_path=url)
return CustomerSubscriptions(self.client, resource_path=f"customers/{self.id}/subscriptions")
Copy link
Copy Markdown
Contributor Author

@whyscream whyscream Jun 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use the result from _get_link, but when it's empty, we still need a working instance of CustomerSubscriptions for creating new subscriptions.

Tom Hendrikx added 2 commits June 22, 2023 19:03
POC for subscriptions only. The subscriptions are one level deep
nested, below a customer. But to retrieve these, we don't need a
customer object. We just need the base resource path, which
might contain a customer id.
https://docs.mollie.com/reference/v2/subscriptions-api/list-subscription-payments
shows what we would call customer subscription payments. These are nested 2 layers deep.
@whyscream whyscream force-pushed the 315-support-listing-nested-objects branch from c3017d6 to 7e7c126 Compare June 22, 2023 17:05
… link is missing

Since the `CustomerSubscriptions` instance also provides access to creating new
subscriptions, we need to initialize it correctly at all times.
Tom Hendrikx added 2 commits June 26, 2023 13:01
@whyscream whyscream force-pushed the 315-support-listing-nested-objects branch from e602b08 to efd724a Compare June 26, 2023 11:04
Refactoring was done by iterating all files in `resources/` from A to Z, and updating code on the go. This is where we stopped half-way :)
@whyscream
Copy link
Copy Markdown
Contributor Author

Issue resolved in #333, closing

@whyscream whyscream closed this Oct 12, 2023
@whyscream whyscream deleted the 315-support-listing-nested-objects branch October 12, 2023 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant